package com.weasel.weixin.commons.message;

import com.google.common.collect.ImmutableMap;
import com.weasel.http.HttpClientSecretary;
import com.weasel.weixin.commons.CommonRequest;
import com.weasel.weixin.commons.CommonResponse;
import com.weasel.weixin.commons.config.CommonConfig;
import com.weasel.weixin.commons.config.CommonConsts;
import com.weasel.weixin.commons.message.bean.template.Industry;

import java.io.IOException;
import java.util.concurrent.ExecutionException;

/**
 * Created by Dylan on 2015/10/21.
 */
public class TemplateMessageRequest extends CommonRequest {


    public TemplateMessageRequest(CommonConfig config) {
        super(config);
    }


    /**
     * 设置公众号所属行业(设置行业可在MP中完成，每月可修改行业1次，账号仅可使用所属行业中相关的模板
     * @param industry1  行业1
     * @param industry2  行业2
     * @return
     * @throws ExecutionException
     * @throws IOException
     */
    public CommonResponse setIndustry(Industry industry1,Industry industry2) throws ExecutionException, IOException {

        CommonResponse response = HttpClientSecretary.post()
                                                     .withURI(getBaseUrl(CommonConsts.INDUSTRY_SETTING_URL))
                                                     .withParams(ImmutableMap.of("industry_id1",industry1.getCode(),"industry_id2",industry2.getCode()))
                                                     .doItWithJson(CommonResponse.class);
        return response;
    }
}
